<?php

namespace app\index\controller;
use app\common\model\CardSignup;
use think\Controller;
use think\Request;
use think\Session;
class Show extends Controller
{

    public function index(){
        if (Request()->isPost()){
            $arr = request()->post();
            $data = $arr;
            $data['ip'] = request()->ip();
            $data['create_time'] = time();
       
            $CardSignup = new CardSignup();
            $only = $CardSignup->where('phone',$arr['phone'])->find();
            if ($only){
                die("<script>alert('您已提交,请勿重复提交。');history.go(-1)</script>");
            }else{
                $res = $CardSignup->allowField(true)->save($data);
                if ($res){
                    die("<script>alert('您已成功提交。');history.go(-1)</script>");
                }else{
                    die("<script>alert('唉呀！服务器开小差了。');history.go(-1)</script>");
                }
            }

        }else{
            if (is_mobile()){
                return $this->fetch('index');
            }else{
                return $this->fetch('mobile');
            }
        }
    }


    public function getsign(){

    }

}
